<?php

abstract class DBMConnection {
	/** attributes */
	private $identification = null;
	private $link = null;
	private $type;
	private $host;
	private $username;
	private $password;
	private $database;
	private $onTransaction = false;
	private $autoCommit = false;
	private $queries = 0;
	private $errors = 0;
	private $transactionOpened = false; 
	private $transactionAutoCommit = false;
	private $cache = null;
	
	/** gets / sets */
	public function getIdentification() {
		return $this->identification;
	}
	public function getLink() {
		return $this->link;
	}
	public function getType() {
		return $this->type;
	}
	public function getHost() {
		return $this->host;
	}
	public function getUsername() {
		return $this->username;
	}
	public function getPassword() {
		return $this->password;
	}
	public function getDatabase() {
		return $this->database;
	}
	public function isOnTransaction() {
		return $this->onTransaction;
	}
	public function isAutoCommit() {
		return $this->autoCommit;
	}
	public function getQueries() {
		return $this->queries;
	}
	public function getErrors() {
		return $this->errors;
	}
	public function isTransactionOpened(){
		return $this->transactionOpened;
	}
	public function isTransactionAutoCommit(){
		return $this->transactionAutoCommit;
	}
	public function getCache(){
		return $this->cache;
	}
	
	public function setIdentification($value) {
		$this->identification = $value;
	}
	public function setLink($value) {
		$this->link = $value;
	}
	public function setType($value) {
		$this->type = $value;
	}
	public function setHost($value) {
		$this->host = $value;
	}
	public function setUsername($value) {
		$this->username = $value;
	}
	public function setPassword($value) {
		$this->password = $value;
	}
	public function setDatabase($value) {
		$this->database = $value;
	}
	public function setOnTransaction($value) {
		$this->onTransaction = $value;
	}
	public function setAutoCommit($value) {
		$this->autoCommit = $value;
	}
	public function setQueries($value) {
		$this->queries = $value;
	}
	public function setErrors($value) {
		$this->errors = $value;
	}
	public function setTransactionOpened($value){
		$this->transactionOpened = $value;
	}
	public function setTransactionAutoCommit($value){
		$this->transactionAutoCommit = $value;
	}
	public function setCache(DBMCache $cache){
		// set the chache
		$this->cache = $cache;
		
		// start the cache
		$this->cache->initialize();
	}
	
	public abstract function connect();
	
	public abstract function disconnect();
	
	public abstract function beginTransaction($autocommit);

	public abstract function rollbackTransaction();
	
	public abstract function commitTransaction();

	public abstract function executeCommand(DBMCommand $command);
	
	public abstract function executeSelect(DBMCommand $command);
	
	public abstract function executeInsert(DBMCommand $command);
	
	public abstract function executeUpdate(DBMCommand $command);
	
	public abstract function executeDelete(DBMCommand $delete);
	
	public abstract function runQuery($sql, $createResultset = false);
	
	public abstract function toSQL(DBMCommand $command);
	
	public abstract function createResultset($sql, $databaseResult, $cache = true);
}
?>